Repository navigation
Name Java identifiers with engine naming - #40
Merged
Merged
Conversation
Add GraphQLType, which names the GraphQL type of a generated class called apart from it (JsonValue for JSONValue), and GraphQLEnum, for enums whose constants follow Java's convention (PER_SESSION) and carry the schema value they stand for. Arguments sends such a constant as its value, and QueryBuilder reads one back by value. Nothing implements them yet: codegen does once a schema's names are formatted by the engine. Signed-off-by: Alex Suraci <alex@dagger.io> Signed-off-by: Yves Brissaud <yves@dagger.io>
The SDK's core classes are named after the schema it was generated from: ID and JSON, or Id and Json once the engine formats the names. The hand-written runtime and the annotation processor compile against whichever was generated, so neither may name them. ModuleDispatcher now takes the JSON scalar class as a type parameter and its from factory from the generated entrypoint. The processor finds the ID and JSON classes, and the FunctionCachePolicy constants, by reflection, and registers a class carrying @GraphQLType under that type. The tests follow the SDK they are compiled with. Signed-off-by: Alex Suraci <alex@dagger.io> Signed-off-by: Yves Brissaud <yves@dagger.io>
On a schema with Query.formatIdentifiers (views from v1.0.0-beta.21), Java names follow Java's conventions as the engine formats them: members camelCase (asJson, withGpu), classes PascalCase (Json, Id, Llm, JsonValue), enum constants SCREAMING_SNAKE (PER_SESSION), with acronyms written as words. A schema without it generates the same code as before, and the engine is never asked. The names come from a names.json beside a plan's schema (daggerengine.names for a single schema), or from the engine, with the schema's __schemaVersion as the dictionary version. Codegen runs in a Maven exec of the SDK module, which joins the session as a nested client; a request without client metadata is served at the engine's own view, which has formatIdentifiers whatever the SDK module's pinned engineVersion is. Without a session it asks through the dagger CLI. When the gate is on and the names can't be formatted, codegen fails rather than generating the schema's names. Renamed methods, setters, accessors and enum constants keep their old names as deprecated aliases. Renamed classes carry @GraphQLType and can't be aliased. Arguments classes keep their names. The prebuilt plugin is rebuilt. Signed-off-by: Alex Suraci <alex@dagger.io> Signed-off-by: Yves Brissaud <yves@dagger.io>
unit-tests also generates and tests the SDK and the annotation processor from the templates module's schema at the engine's version. From v1.0.0-beta.21 that schema has Query.formatIdentifiers, so this covers the engine-formatted names, formatted through the exec's nested session; the existing run covers the module's own view. Signed-off-by: Alex Suraci <alex@dagger.io> Signed-off-by: Yves Brissaud <yves@dagger.io>
JSON-B applies an enum's class-level serializer to a field, but not to an element of a list it serializes, so a function returning a list of a renamed core enum sent the constants' names (PER_SESSION) instead of their values (PerSession). Under formatted names, JsonConverter.toJSON now replaces enum constants with their values in collections and arrays too, through GraphQLEnums.values. Signed-off-by: Alex Suraci <alex@dagger.io> Signed-off-by: Yves Brissaud <yves@dagger.io>
The second test run generates into the target/ the first one filled, and codegen leaves the classes formatted names rename (JSON.java, ...) in place, so they compiled beside Json.java. Signed-off-by: Alex Suraci <alex@dagger.io> Signed-off-by: Yves Brissaud <yves@dagger.io>
Signed-off-by: Alex Suraci <alex@dagger.io> Signed-off-by: Yves Brissaud <yves@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
Engines from v1.0.0-beta.26 format names only under Query.naming and spell cache policies NEVER, PER_SESSION and DEFAULT. The SDK module declares the floor, whose view spells introspectionSchemaJson. Signed-off-by: Yves Brissaud <yves@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
eunomie
force-pushed
the
identifier-casing
branch
from
November 21, 2026 13:04
13750ae to
7db90cd
Compare
eunomie
marked this pull request as ready for review
November 21, 2026 16:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of the identifier casing work (dagger/dagger#14501, reference implementation dagger/dagger#14680) to java-sdk.
Note
Rebased on main (a8ac904); stacked with #45, which moves the e2e checks to the engine that runs them and ports collections to filtered views; the engine-e2e floor and below-floor checks of this PR's CI are removed there, so this PR alone is red until the stack merges.
A module on the entrypoint targets
v1.0.0-beta.28. The SDK module declares the floorv1.0.0-beta.26(engineVersion), whose view spellsintrospectionSchemaJson. sdk-helpers isv1.0.12.How the names are formatted
Generated Java names follow Java's conventions, as the engine formats them. There is no version gate: codegen always asks the engine, with
Query.naming(version:).formatIdentifiers(engines from v1.0.0-beta.26). The Maven codegen plugin asks the engine directly:$DAGGER_SESSION_PORT,$DAGGER_SESSION_TOKEN). The batched query has three aliases,CAMEL:CAPITALIZED,PASCAL:CAPITALIZEDandSCREAMING_SNAKE:UPPERCASE, and always passesversion: <the schema's __schemaVersion>, so the naming dictionary follows the schema and not the session's view.dagger query --var-json.names.jsonbeside a plan's schema, ordaggerengine.names, can supply the names offline.Warning
This relies on undocumented engine behaviour. An exec started by a module on the legacy
dangruntime carries no module context:withExecDynamicInputsonly attaches one for v2 entrypoint modules. A nested-session request without client metadata headers is then served atengine.Version, the engine's own view.What changes
Codegen plugin
FormattedNamesandEngineQueriesare new. Names are formatted like this:asJSON,withGPU,insecureSkipTLSVerifyasJson(),withGpu(),insecureSkipTlsVerifyJSON,ID,LLM,JSONValue,HTTPState, ...Json,Id,Llm,JsonValue,HttpState, ...PerSession,GzipPER_SESSION,GZIP@GraphQLType("…").GraphQLEnum, so they serialize and deserialize through their values. A value and its alias share one constant.with…setters, input accessors and enum constants keep their schema names as@Deprecatedaliases. Interfaces keep them as default methods. A name the schema already spells the Java way gets no alias.…Argumentsclasses keep their names.Runtime
GraphQLType,GraphQLEnum,GraphQLEnums,GraphQLEnum{Serializer,Deserializer}.Argumentssends aGraphQLEnumconstant as its value.QueryBuilderreads a returned enum back by its value.JsonConverter.toJSONalso converts enums inside lists and arrays. JSON-B skips an enum's class-level serializer for list elements.ModuleDispatcheris generic over the JSON scalar class, which it can no longer name.Annotation processor
ID/JSONorId/Jsonthe SDK has, found by reflection.@GraphQLTypeunder its GraphQL name.FunctionCachePolicy.NEVER/PER_SESSION/DEFAULTwhen the SDK has them.EntrypointpassesJSON::from(orJson::from) toModuleDispatcher.NEVER,PER_SESSIONandDEFAULT, the only spellings engines from v1.0.0-beta.26 resolve.Entrypoint
dang.tomlThe entrypoint's
dang.tomlhas one writer, the one #44 added. This PR no longer adds a second writer, nor its logic that never moved an existing module.Packager
unit-testsalso generates and tests the SDK and the annotation processor at the engine's own view, which covers the engine-formatted names.Breaking changes
ID→Id,JSON→Json,JSONValue→JsonValue,HTTPState→HttpState,SDKConfig→SdkConfig,WorkspaceSDK→WorkspaceSdk, and everyLLM*→Llm*.HTTPClient→HttpClient.JSON.javaandJson.javawould collide on case-insensitive file systems.asJsonandPER_SESSION, so the deprecated aliasesasJSON()andFunctionCachePolicy.PerSessionare no longer generated for core. Code that uses them moves toasJson()andPER_SESSION.@Deprecated static finalfields. They are not constants: on a schema that spellsPerSession,case PerSession:doesn't compile,name()returnsPER_SESSION, andEnum.valueOf(…, "PerSession")throws.-Werrorbuilds break.ModuleDispatcher's signatures changed. It's internal and regenerated with the entrypoint, but every module'sEntrypoint.javaandsha256sumschange once on the nextdagger generate.Tests
Ran on a v1.0.0-beta.28 engine:
packager:unit-tests: plugin, SDK and processor unit tests, plus the run at the engine's own view.FormattedNamesTest,FormattedNamesCodegenTest,EngineQueriesTestandGraphQLEnumsTest. They cover a names file, the engine query (the nested session with basic auth and no client metadata, or the CLI), and the failure path (engine error, short answer, HTTP errors).packager:generate:staleandtemplates:generate:stale.e2eentrypoint/*checks.CI on this PR alone:
engine-e2e/floor-checkfails on the v1.0.0-beta.26 floor engine: five collection checks (the engine removedbatchin v1.0.0-beta.22; Catch up with the other SDKs: e2e on the engine that runs them #45 ports them) and two Go checks that only fail on that engine build.engine-e2e/below-floor-checkfails because the SDK module now uses v1.0.0-beta.26 APIs.